package kursynbp;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Connection;
import java.util.Date;

public class ExchangeRate {

	private Exchange exchange;
	private Date date;
	private BigDecimal value;
	
	public Exchange getExchange() {
		return exchange;
	}
	
	public void setExchange(Exchange curr) {
		this.exchange = curr;
	}
	
	public Date getDate() {
		return date;
	}
	
	public void setDate(Date date) {
		this.date = date;
	}
	
	public BigDecimal getValue() {
		return value;
	}
	
	public void setValue(BigDecimal value) {
		this.value = value.setScale(3, RoundingMode.HALF_DOWN);
	}

	public static ExchangeRate getExchangeRate(Connection connection, Date date, String currCode) {

		return ExchangeRateDAO.findExchangeRate(connection, date, currCode);
	}

	public static ExchangeRate getLowestExchangeRate(Connection connection, Date date) {

		return ExchangeRateDAO.findLowestExchangeRate(connection, date);
	}

	public static ExchangeRate getHighestExchangeRate(Connection connection, Date date) {

		return ExchangeRateDAO.findHighestExchangeRate(connection, date);
	}
	
	public static ExchangeRate getLowestExchangeRate(Connection connection, Date from, Date to) {

		return ExchangeRateDAO.findLowestExchangeRate(connection, from, to);
	}

	public static ExchangeRate getHighestExchangeRate(Connection connection, Date from, Date to) {

		return ExchangeRateDAO.findHighestExchangeRate(connection, from, to);
	}
	
	public static ExchangeRate getLowestExchangeRate(Connection connection, Date from, Date to, String exCode) {
		
		return ExchangeRateDAO.findLowestExchangeRate(connection, from, to, exCode);
	}
	
	public static ExchangeRate getHighestExchangeRate(Connection connection, Date from, Date to, String exCode) {
		
		return ExchangeRateDAO.findHighestExchangeRate(connection, from, to, exCode);
	}
	
	public static ExchangeRateDiff getBiggestExchangeDiff(Connection connection, Date from, Date to) {
		
		ExchangeRateDiff retCrd = ExchangeRateDAO.findBiggestExchangeDiff(connection, from, to);
		
		return retCrd;
	}
}
